package com.ruoyi.api.controller;

import com.ruoyi.admin.service.PaperService;
import com.ruoyi.admin.service.UserModuleService;
import com.ruoyi.admin.service.UserPaperService;
import com.ruoyi.api.model.request.ModuleSubmitReq;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/paper")
public class ApiPaperController {

    @Autowired
    private PaperService paperService;

    @Autowired
    private UserModuleService userModuleService;

    @Autowired
    private UserPaperService userPaperService;

    /**
     * 试卷详情
     * @param paperId
     * @return
     */
    @GetMapping("paperDetail")
    public AjaxResult paperDetail(Long paperId){
        return AjaxResult.success(this.paperService.paperDetail(paperId));
    }


    /**
     * 模块提交
     * @param moduleSubmitReq
     * @return
     */
    @PostMapping("submitModule")
    public AjaxResult submitModule(@RequestBody ModuleSubmitReq moduleSubmitReq){
        return AjaxResult.success(this.userModuleService.submitModule(moduleSubmitReq));
    }

    /**
     * 试卷提交
     * @param userPaperId
     * @return
     */
    @PostMapping("submitPaper")
    public AjaxResult submitPaper(@RequestBody Long userPaperId){
        return AjaxResult.success(userPaperService.submitPaper(userPaperId));
    }
}
